package main.service;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.List;

public class WUtil {
	public static String writeStringToFile(String data, String fileName) {

        File saveDirFile = new File(EmailUtils.SAVE_DIR);
        if (!saveDirFile.exists())
            saveDirFile.mkdir();

        String savePath = EmailUtils.SAVE_DIR + "\\"+fileName+".txt";

        try {

            File file = new File(savePath);
            if (!file.exists()) {
                file.createNewFile();
            }
            PrintStream ps = new PrintStream(new FileOutputStream(file));
            ps.println(data);// 往文件里写入字符串
        } catch (Exception e) {
            e.printStackTrace();
        }
        return savePath;
    }
}
